package model;
import org.newdawn.slick.SlickException;

public final class Wrapper {
	
	// Singleton
	private static Wrapper instance;

	private Mister mister;
	private Level level;
	
	static {
		instance = new Wrapper();
	}
	
	private Wrapper() {
		try {
			mister = new Mister(.5, 0);
		} catch (SlickException e) {
			e.printStackTrace();
		}
		level = new Level();
	}
	
	public static Wrapper getInstance() {
		return instance;
	}
	
	public double getMisterX() {
		return mister.getX();
	}
	
	public double getMisterY() {
		return mister.getY();
	}
	
	public double getMisterXGeschwindigkeit() {
		return mister.getGeschwindigkeitX();
	}
	
	public void setMisterXGeschwindigkeit(double v) {
		mister.setGeschwindigkeitX(v);
	}
	
	public double getMisterYGeschwindigkeit() {
		return mister.getGeschwindigkeitY();
	}
	
	public void setMisterYGeschwindigkeit(double v) {
		mister.setGeschwindigkeitY(v);
	}

	public void setMisterX(double x) {
		mister.setX(x);
	}

	public void setMisterY(double y) {
		mister.setY(y);
	}

	public boolean isMisterAlive() {
		//return true;
		return (mister.getY() + mister.getHeight() > 0) && !mister.isDead();
	}

	public double getMisterWidth() {
		return mister.getWidth();
	}

	public double getMisterHeight() {
		return mister.getHeight();
	}
	
	public void killMister() {
		mister.kill();
	}
	
	public boolean isMisterDead() {
		return mister.isDead();
	}

	public void schiessen(double startX, double startY, double angle) throws SlickException {
		level.schiessen(startX, startY, angle);
	}

	public void schiebeSichtfenster(double y) {
		level.schiebeSichtfenster(y);
		setMisterY(getMisterY() - y);
		//Viewport.moveUpwards(y);
	}

	public double getPoints()
	{
		return level.getPoints();
	}
	
	public Item[] holeSichtfenster() {
		return level.update();
	}
	
	public static void reset()
	{
		try
		{
			instance.mister = new Mister(.5, 0);
			instance.level = new Level();
		}
		catch (SlickException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
